//
//  TMPlan.h
//  cutter
//
//  Created by mac on 15/12/30.
//  Copyright © 2015年 e360. All rights reserved.
//
#import "TMMath.h"
#import <UIKit/UIKit.h>

@class TMPlanVertex;
@protocol TMPlanElement <NSObject>
-(id<TMPlanElement>)hitTest:(TMPlanVertex*)vertex error:(CGFloat)error;
@end

//顶点
@interface TMPlanVertex : NSObject <TMPlanElement>
@property(assign, nonatomic) CGFloat x;
@property(assign, nonatomic) CGFloat y;
@property(assign, nonatomic) CGPoint point;
@property(assign, nonatomic) NSUInteger type;
@property(assign, nonatomic) NSUInteger count;
-(id<TMPlanElement>)hitTest:(TMPlanVertex*)vertex error:(CGFloat)error;
-(instancetype)initWithPoint:(CGPoint)point;
-(instancetype)clone;
@end

//面
@interface TMPlanFace : NSObject <TMPlanElement>
@property(strong, nonatomic) TMPlanVertex* to;
@property(strong, nonatomic) TMPlanVertex* from;
-(id<TMPlanElement>)hitTest:(TMPlanVertex*)vertex error:(CGFloat)error;
@end

//墙
@class TMPlanDoor;
@interface TMPlanWall : NSObject <TMPlanElement>
@property(strong, nonatomic) TMPlanVertex* to;
@property(strong, nonatomic) TMPlanVertex* from;
@property(strong, nonatomic) TMPlanFace *positive;//正面
@property(strong, nonatomic) TMPlanFace *negative;//反面
-(id<TMPlanElement>)hitTest:(TMPlanVertex*)vertex error:(CGFloat)error;
-(void)addDoor:(TMPlanDoor*)door;
-(void)delDoor:(TMPlanDoor*)door;
@end

//门
@interface TMPlanDoor : NSObject <TMPlanElement>
@property(assign, nonatomic) CGFloat x;
@property(assign, nonatomic) CGFloat y;
@property(assign, nonatomic) CGFloat width;
@property(assign, nonatomic) CGFloat height;
-(id<TMPlanElement>)hitTest:(TMPlanVertex*)vertex error:(CGFloat)error;
@end


@interface TMPlanRoom : NSObject <TMPlanElement>
@end
//
//
@interface TMPlan : UIView
@end
